/*  
 * 常规cookie操作
 * @Author: beautifulHao 
 * @Date: 2019-07-17 14:57:12
 * @Last Modified by: beautifulHao
 * @Last Modified time: 2019-07-17 14:57:33
 */
export default {
  get (key) {
    if (key) {
      var regexpStr = "(?:^|.*;\\s*)" +
        escape(key).replace(/[\-\.\+\*]/g, "\\$&") +
        "\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*"
      return unescape(document.cookie.replace(new RegExp(regexpStr), "$1"))
    }
  },
  set (key, value, exp) {
    if (key) {
      if (exp instanceof Date) {
        document.cookie = escape(key) + "=" + escape(value) +";expires="+exp.toGMTString()+ ";path=/"
      }
      else {
        document.cookie = escape(key) + "=" + escape(value)+ ";path=/"
      }
    }

  },
  remove (key) {
    if (!key) {
      return
    }
    document.cookie = escape(key) + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/"
  }
}